/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ylystudio.pms.ejb.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "knowledge_title_item")
@NamedQueries({
    @NamedQuery(name = "KnowledgeTitleItem.findAll", query = "SELECT k FROM KnowledgeTitleItem k"),
    @NamedQuery(name = "KnowledgeTitleItem.findByKtiId", query = "SELECT k FROM KnowledgeTitleItem k WHERE k.ktiId = :ktiId"),
    @NamedQuery(name = "KnowledgeTitleItem.findByKtiName", query = "SELECT k FROM KnowledgeTitleItem k WHERE k.ktiName = :ktiName")})
public class KnowledgeTitleItem implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "kti_id")
    private Integer ktiId;
    @Basic(optional = false)
    @Column(name = "kti_name")
    private String ktiName;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "knowledgeTitleItem", fetch = FetchType.LAZY)
    private List<Knowledge> knowledgeList;
    @JoinColumn(name = "kt_id", referencedColumnName = "kt_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private KnowledgeTitle knowledgeTitle;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "knowledgeTitleItem", fetch = FetchType.LAZY)
    private List<KnowledgeTitleItem> knowledgeTitleItemList;
    @JoinColumn(name = "kti_former", referencedColumnName = "kti_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private KnowledgeTitleItem knowledgeTitleItem;

    public KnowledgeTitleItem() {
    }

    public KnowledgeTitleItem(Integer ktiId) {
        this.ktiId = ktiId;
    }

    public KnowledgeTitleItem(Integer ktiId, String ktiName) {
        this.ktiId = ktiId;
        this.ktiName = ktiName;
    }

    public Integer getKtiId() {
        return ktiId;
    }

    public void setKtiId(Integer ktiId) {
        this.ktiId = ktiId;
    }

    public String getKtiName() {
        return ktiName;
    }

    public void setKtiName(String ktiName) {
        this.ktiName = ktiName;
    }

    public List<Knowledge> getKnowledgeList() {
        return knowledgeList;
    }

    public void setKnowledgeList(List<Knowledge> knowledgeList) {
        this.knowledgeList = knowledgeList;
    }

    public KnowledgeTitle getKnowledgeTitle() {
        return knowledgeTitle;
    }

    public void setKnowledgeTitle(KnowledgeTitle knowledgeTitle) {
        this.knowledgeTitle = knowledgeTitle;
    }

    public List<KnowledgeTitleItem> getKnowledgeTitleItemList() {
        return knowledgeTitleItemList;
    }

    public void setKnowledgeTitleItemList(List<KnowledgeTitleItem> knowledgeTitleItemList) {
        this.knowledgeTitleItemList = knowledgeTitleItemList;
    }

    public KnowledgeTitleItem getKnowledgeTitleItem() {
        return knowledgeTitleItem;
    }

    public void setKnowledgeTitleItem(KnowledgeTitleItem knowledgeTitleItem) {
        this.knowledgeTitleItem = knowledgeTitleItem;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ktiId != null ? ktiId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof KnowledgeTitleItem)) {
            return false;
        }
        KnowledgeTitleItem other = (KnowledgeTitleItem) object;
        if ((this.ktiId == null && other.ktiId != null) || (this.ktiId != null && !this.ktiId.equals(other.ktiId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ylystudio.pms.ejb.entity.KnowledgeTitleItem[ktiId=" + ktiId + "]";
    }

}
